package org.usp.poli.bipt.client.chart;

import com.google.gwt.visualization.client.AbstractDataTable;
import com.google.gwt.visualization.client.VisualizationUtils;
import com.google.gwt.visualization.client.DataTable;
import com.google.gwt.visualization.client.Selection;
import com.google.gwt.visualization.client.AbstractDataTable.ColumnType;
import com.google.gwt.visualization.client.events.SelectHandler;
import com.google.gwt.visualization.client.visualizations.BarChart;
import com.google.gwt.visualization.client.visualizations.ColumnChart;
import com.google.gwt.visualization.client.visualizations.PieChart;
import com.google.gwt.visualization.client.visualizations.PieChart.Options;
import com.google.gwt.visualization.client.visualizations.Visualization;

public class Chart  {
	PieChart pie;
	ColumnChart column;
	BarChart bar;
	
	public Chart(String title, AbstractDataTable data,String tipo) {
		
		if (tipo == "pie"){
			pie = new PieChart(data, createOptionsP(title));
       // pie.addSelectHandler(createSelectHandler(pie));
		}
		else if(tipo== "column"){
			
			column = new ColumnChart(data, createOptionsC(title));
		}
		else if(tipo == "bar"){
	
			bar = new BarChart(data, createOptionsB(title));
		
		}
		
	}
	
public PieChart getGraphicP(){
		
		
		return pie;
	}
public ColumnChart getGraphicC(){
	
	
	return column;
}
public BarChart getGraphicB(){
	
	
	return bar;
}
	
	
	
	private Options createOptionsP(String nome) {
	    Options options = Options.create();
	    options.setWidth(400);
	    options.setHeight(240);
	    options.set3D(true);
	    options.setTitle(nome);

	    return options;
	  }
	private com.google.gwt.visualization.client.visualizations.ColumnChart.Options createOptionsC(String nome) {
	    com.google.gwt.visualization.client.visualizations.ColumnChart.Options options = com.google.gwt.visualization.client.visualizations.ColumnChart.Options.create();
	    options.setWidth(400);
	    options.setHeight(240);
	    options.set3D(true);
	    options.setTitle(nome);
	    options.setTitleX(nome);
	    return options;
	  }
	private com.google.gwt.visualization.client.visualizations.BarChart.Options createOptionsB(String nome) {
	    com.google.gwt.visualization.client.visualizations.BarChart.Options options = com.google.gwt.visualization.client.visualizations.BarChart.Options.create();
	    options.setWidth(400);
	    options.setHeight(240);
	    options.set3D(true);
	    options.setTitle(nome);
	    options.setTitleY(nome);
	    //{width: 400, height: 240, title: 'Company Performance',
        //    vAxis: {title: 'Year', titleTextStyle: {color: 'red'}}
        //   }
	    return options;
	  }

}
